package com.starwish.starwishblog.mapper;

import com.starwish.starwishblog.entity.Role;
import com.starwish.starwishblog.vo.RoleVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Role record);

    Role selectByPrimaryKey(Long id);

    List<Role> selectAll();

    int updateByPrimaryKey(Role record);


    List<Role> selectRoleByName(String name);

    @Delete("delete from t_manager_role where role_id = #{value}")
    int deleteManagerRoleByRoleId(Integer id);

    @Delete("delete from t_role_url_permission where role_id = #{value}")
    int deleteRolePermissionByRoleId(Integer id);

    List<RoleVo> selectRoleVoByCons(String name);

    List<RoleVo> selectRoleVoByName(String name);

    List<Integer> selectPerIdsByRoleKey(@Param("id") Integer id);

    void insertBatchRoleAndPer(@Param("rid") Integer id,@Param("perIds") List<Integer> checkedIds);

    List<Role> selectRolesByManagerId(Integer id);
}